package com.zlm.mall;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;

/**
 * @Author: 郑
 *
 * 逻辑删除
 * 1.(可以省略)
 * mybatis-plus:
 *   global-config:
 *     db-config:
 *       logic-delete-value: 1 #逻辑已删除(默认1)
 *       logic-not-delete-value: 0 #逻辑未删除(默认0)
 *
 * 使用redisson分布式锁
 * 1) 引入依赖
 * 2)配置redisson
 *  @Bean(destroyMethod = "shutdown")
 *     public RedissonClient redissonClient()throws IOException{
 *         //创建配置
 *         Config config = new Config();
 *         config.useSingleServer().setAddress("redis://127.0.0.1:6379");
 *         //根据配置创建RedissonClient实例
 *         return Redisson.create(config);
 *     }
 *
 * 使用spring-cache减化缓存
 * 1)引入 <dependency>
 *             <groupId>org.springframework.boot</groupId>
 *             <artifactId>spring-boot-starter-cache</artifactId>
 *         </dependency>
 *         redis
 * 2) 写配置
 *      1. 配置使用redis作为缓存  spring.cache.type=redis
 * 3) 使用
 * @Cacheable 保存缓存
 * @CacheEvict 删除缓存
 * @CachePut 更新缓存
 * @Caching 组合多个注解
 * @CacheConfig 在类级别共享缓存的相同配置
 *
 *开启缓存 @EnableCaching
 *
 * @Cacheable 自定义
 *       设置缓存 key   key=""
 *      设置缓存ttl   yml里配置 spring.redis.time-to-live   毫秒
 *      保存为json
 *
 */
@EnableCaching
@MapperScan(basePackages = "com.zlm.mall.product.dao")
@EnableFeignClients(basePackages = "com.zlm.mall.product.feign")
@EnableDiscoveryClient
@SpringBootApplication
public class MallProductApplication {
    public static void main(String[] args) {
        SpringApplication.run(MallProductApplication.class, args);
    }
}
